<%@page import="entities.OrderEntity"%>
<%@page import="service.OrderService"%>
<%@page import="service.SellerService"%>
<%@page import="service.CommentService"%>
<%@page import="entities.SellerEntity"%>
<%@page import="entities.CommentEntity"%>

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

	String sellerName = (String) session.getAttribute("sellerName");
	String password = (String) session.getAttribute("sellerpassword");
	SellerEntity seller = new SellerEntity();
	if (sellerName == null || password == null) {
		response.sendRedirect("index.jsp");
	} else {
		seller = SellerService.confirm(sellerName, password.trim());
	}
	//针对分页的
	//每页的记录数
	int pageSize = 10;
	//总评论数
	int count = CommentService.getSellerCommentCount(sellerName);
	//总共的页数 
	int pageCount = count % pageSize == 0 ? count / pageSize : (count
			/ pageSize + 1);
	String pageIndex = request.getParameter("pageIndex");
	if (null == pageIndex) {
		pageIndex = "1";
	}
	int pageNow = Integer.parseInt(pageIndex);
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>评论查看</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>

<link rel="stylesheet" type="text/css" href="<%=basePath%>css/goodsDetail.css">
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/cart.css">
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>user/css/user.css">


<style type="text/css">

/*订单信息*/
.orderInfo {
	border-bottom: 1px solid #ccc;
	padding: 5px;
}

.orderInfo div {
	margin-bottom: 3px;
}

.orderInfo span {
	color: #15ADFF;
	font-size: 14px;
}
/*订单号*/
.orderInfo span.orderNo {
	color: red;
	font-weight: bold;
	font-size: 20px;
	margin-bottom: 10px;
}

.orderInfo .detail {
	font-size: 12px;
	padding: 2px;
	margin-right: 5px;
	color: white;
	background-color: #15ADFF;
}

.orderInfo .detail:hover {
	background-color: #7CDAEF;
	color: red;
}
.page{
	width: 700px;
	text-align: center;
	margin-top: 8px;
    font-size: 14px;
}
.page span{
	padding: 0 6px;
	color: #ff74a9;
}
.page a{
	margin: 0 2px;
}

.page a:hover{
	color: #ff74a9;
}

</style>
</head>

<body>
	<jsp:include page="header.jsp"></jsp:include>
	<div class="center"  style="width: 600px;">
		<!-- 评论列表 begin -->
		<div class="comments">
			<ul class="comment_list">
				<%
					List<CommentEntity> comments = new ArrayList<CommentEntity>();
					comments = CommentService.getSelelrComment(sellerName, ""
							+ (pageNow - 1) * pageSize, pageSize + "");
					for (int i = 0; i < comments.size(); i++) {
				%>
				<li class="comment"><a
					href="goodsDetail.jsp?goodsId=<%=comments.get(i).getGoodsId()%>"
					target="_blank"> <img class="head"
						src="<%=comments.get(i).getGoodsImg()%>"
						alt="<%=comments.get(i).getGoodsName()%>"> </a>
					<p class="sms">
						<a
							href="goodsDetail.jsp?goodsId=<%=comments.get(i).getGoodsId()%>"
							target="_blank"><%=comments.get(i).getGoodsName()%></a> : <span
							class="comment_title"><%=comments.get(i).getTitle()%></span><span>&nbsp;&nbsp;&nbsp;打分：<b
							style="color: red;"><%=comments.get(i).getRank()%></b> </span>
					</p>
					<p class="sms"><%=comments.get(i).getContent()%><span>&nbsp;&nbsp;&nbsp;<%=comments.get(i).getTime()%></span>
					</p>
				</li>
				<%
					}
				%>

			</ul>

			<div class="page">
				共:<span><%=pageCount%></span>页(共<%=count%>条)；&nbsp;&nbsp;&nbsp;每页<span><%=pageSize%></span>条记录；&nbsp;&nbsp;当前为第<span><%=pageCount == 0 ? 0 : pageNow%></span>页。<br />
				<%
					if (pageNow > 1) {
				%>
				<a
					href="_seller/commentManage.jsp?action=comment&pageIndex=<%=pageNow - 1%>">上一页</a>
				<%
					} else {
				%>
				<a title="没有上一页啦">上一页</a>
				<%
					}
					if (pageNow < pageCount) {
				%>
				<a
					href="_seller/commentManage.jsp?action=comment&pageIndex=<%=pageNow + 1%>">下一页</a>
				<%
					} else {
				%>
				<a title="没有下一页啦">下一页</a>
				<%
					}
				%>
				<a href="_seller/commentManage.jsp?action=comment">首页</a> <a
					href="_seller/commentManage.jsp?action=comment&pageIndex=<%=pageCount == 0 ? 1 : pageCount%>">末页</a>
			</div>
		</div>
		<!-- 评论列表 end -->
	</div>
</body>
</html>
